<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\AgentController;
use App\Http\Controllers\GoodCateController;
use App\Http\Controllers\GoodController;

//no auth
Route::get('/', [UserController::class,'login'])->name('login');
Route::get('/captcha', [UserController::class,'captcha']);
Route::post('/verifyLogin', [UserController::class,'verifyLogin']);

Route::middleware(['auth'])->group(function () {
    //admin and agent web
    Route::get('/index', [IndexController::class,'index']);
    Route::get('/logout', [IndexController::class,'logout']);
    Route::get('/init', [IndexController::class,'init']);

    //admin auth agent web
    Route::prefix('agent')->group(function () {
        Route::get('index', [AgentController::class,'index']);
        Route::get('create', [AgentController::class,'create']);
        Route::get('edit', [AgentController::class,'edit']);
    });

    //admin auth user web
    Route::prefix('user')->group(function () {
        Route::get('role', [UserController::class,'role']);
        Route::get('createRole', [UserController::class,'createRole']);
        Route::get('index', [UserController::class,'index']);
        Route::get('createUser', [UserController::class,'createUser']);
    });

    //admin auth goods web
    Route::prefix('goods')->group(function () {
        Route::get('cate', [GoodCateController::class,'cate']);
        Route::get('index', [GoodController::class,'index']);
        Route::get('create', [GoodController::class,'create']);
        Route::get('edit', [GoodController::class,'edit']);
    });

    //admin auth agent api
    Route::prefix('api/agent')->group(function () {
        Route::get('list',[AgentController::class, 'list']);
        Route::get('delete',[AgentController::class, 'delete']);
        Route::post('store',[AgentController::class, 'store']);
        Route::post('update',[AgentController::class, 'update']);
        Route::get('recharge',[AgentController::class, 'recharge']);
    });

    //admin auth goods api
    Route::prefix('api/goods')->group(function () {
        Route::get('cateList',[GoodCateController::class, 'cateList']);
        Route::post('cateStore',[GoodCateController::class, 'cateStore']);
        Route::post('cateUpdate',[GoodCateController::class, 'cateUpdate']);
        Route::post('upload', [GoodController::class, 'upload']);
        Route::post('store', [GoodController::class, 'store']);
        Route::get('list', [GoodController::class, 'list']);
        Route::post('update', [GoodController::class, 'update']);
        Route::get('delete', [GoodController::class, 'delete']);
    });

    //admin auth user api
    Route::prefix('api/user')->group(function () {
        Route::get('role', [UserController::class, 'roleList']);
        Route::post('storeRole', [UserController::class, 'storeRole']);
        Route::get('index', [UserController::class, 'userList']);
        Route::post('storeUser', [UserController::class, 'storeUser']);
    });

});


